//
//  ScreenTableViewController.m
//  Car
//
//  Created by lanou on 15/9/21.
//  Copyright (c) 2015年 朱鸿儒. All rights reserved.
//

#import "ScreenTableViewController.h"
#import "DetailScreenTableViewController.h"
#import "ShuaiXuanTableViewController.h"


@interface ScreenTableViewController ()

@end

@implementation ScreenTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpData];
}
- (void)setUpData{
//    self.tableView.separatorStyle = 0;
    
    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:(UIBarButtonSystemItemSearch) target:self action:@selector(searchButtonClick:)];
    self.navigationItem.rightBarButtonItem = rightButton;
    
    UIBarButtonItem *aButton = [[UIBarButtonItem alloc]initWithTitle:@"品牌" style:(UIBarButtonItemStyleDone) target:self action:@selector(aButtonClick:)];
    UIBarButtonItem *bButton = [[UIBarButtonItem alloc]initWithTitle:@"筛选" style:(UIBarButtonItemStyleDone) target:self action:@selector(bButtonClick:)];
    UIBarButtonItem *cButton = [[UIBarButtonItem alloc]initWithTitle:@"降价" style:(UIBarButtonItemStyleDone) target:self action:@selector(cButtonClick:)];
    UIBarButtonItem *dButton = [[UIBarButtonItem alloc]initWithTitle:@"二手车" style:(UIBarButtonItemStyleDone) target:self action:@selector(dButtonClick:)];
    NSArray *buttonArray = [[NSArray alloc]initWithObjects:aButton,bButton,cButton,dButton, nil];
    self.navigationItem.leftBarButtonItems = buttonArray;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    
}

- (void)aButtonClick:(UIBarButtonItem *)button{
    FindTableViewController *findVC = [[FindTableViewController alloc]init];
    SaleTableViewController *saleVC = [[SaleTableViewController alloc]init];
    IIViewDeckController *deckVC = [[IIViewDeckController alloc]initWithCenterViewController:findVC leftViewController:saleVC];
    deckVC.leftSize = 75;
    [self.navigationController pushViewController:deckVC animated:NO];
    
    
}
- (void)bButtonClick:(UIBarButtonItem *)button{
    ScreenTableViewController *screenVC = [[ScreenTableViewController alloc]init];
    [self.navigationController pushViewController:screenVC animated:NO];
}
- (void)cButtonClick:(UIBarButtonItem *)button{
    MarkDownTableViewController *markDownVC = [[MarkDownTableViewController alloc]init];
    [self.navigationController pushViewController:markDownVC animated:NO];
}
- (void)dButtonClick:(UIBarButtonItem *)button{
    UsedCarTableViewController *usedCarVC = [[UsedCarTableViewController alloc]init];
    [self.navigationController pushViewController:usedCarVC animated:NO];
}

- (void)searchButtonClick:(UIBarButtonItem *)rightButton{
    
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 7;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    if (indexPath.row == 6 ) {
        cell.textLabel.backgroundColor = [UIColor lightGrayColor];
        cell.textLabel.textAlignment = NSTextAlignmentCenter;
        
    }
    NSArray *arr = @[@"品牌",@"国别",@"座位",@"驱动",@"燃料",@"排量",@"查看符合条件的车辆"];
    cell.textLabel.text = arr[indexPath.row];
   
    
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 6) {
        ShuaiXuanTableViewController *shuaiXuanVC = [[ShuaiXuanTableViewController alloc]init];
        [self.navigationController pushViewController:shuaiXuanVC animated:YES];
    }else{
    DetailScreenTableViewController *detailSreenVC = [[DetailScreenTableViewController alloc]init];
    detailSreenVC.index = (NSInteger *)indexPath.row;
    [self.navigationController pushViewController:detailSreenVC animated:YES];
    }
}



@end
